package org.vnl.platform.orm;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

/**
 * 執行存取的指令
 * 
 * @author Vaughan
 *
 */
public class Command implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = -1305230062715093645L;

    private String name;
    private List<CommandParameter> condition;
    private Object entity;
    
    public Command() {
        this(null);
    }
    
    public Command(String name) {
        this.name = name;
        this.condition = new LinkedList<CommandParameter>();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<CommandParameter> getCondition() {
        return condition;
    }

    public void setCondition(List<CommandParameter> condition) {
        this.condition = condition;
    }
    
    public void addParam(Object value) {
        CommandParameter qcp = new CommandParameter(value);
        this.condition.add(qcp);
    }
    
    public void addParam(String name, Object value) {
        CommandParameter qcp = new CommandParameter(name, value);
        this.condition.add(qcp);
    }
    
    public void addParam(String name, Object value, ORMTypes type) {
        CommandParameter qcp = new CommandParameter(name, value, type);
        this.condition.add(qcp);
    }

    public Object getEntity() {
        return entity;
    }

    public void setEntity(Object entity) {
        this.entity = entity;
    }
    
}
